package org.dragonnova.meetingclient.client.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import org.dragonnova.meetingclient.client.activity.MainActivity;

/**
 * Created by Administrator on 2015/12/10 18:43.
 * Author: songxy
 * Email: thinkdata@163.com
 */
public class BootSelfBroadcastReceiver extends BroadcastReceiver {

    private static final String SHUTDOWN_ACTION = "android.intent.action.ACTION_SHUTDOWN";

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
            Intent mainActivity = new Intent(context, MainActivity.class);
            mainActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(mainActivity);
        } else if (intent.getAction().equals(SHUTDOWN_ACTION)) {
            android.os.Process.killProcess(android.os.Process.myPid());
        }
    }
}
